package in.muton.edushare.url;

import in.muton.edushare.EduShareSession;
import in.muton.edushare.url.URLLoader;

import org.apache.wicket.markup.html.WebPage;

import com.edushare.common.constants.URLConstants;
import com.edushare.common.vo.Schedules;

public class URLHelper {
	
	/**
	 * @return course private page if logged-in user, else public page
	 */
	public static final Class<? extends WebPage> getCourseHomeClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.COURSE_PROFILE_PATH);
		else
			return URLLoader.getPageClass(URLConstants.COURSE_PUBLIC_PAGE_HOME);
	}
	
	public static final Class<? extends WebPage> getCoursePeoplePageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.COURSE_PEOPLE);
		else
			return URLLoader.getPageClass(URLConstants.COURSE_PUBLIC_PAGE_PEOPLE);
	}
	
	/**
	 * 
	 * @return dept private page if logged-in user, else public page
	 */
	public static final Class<? extends WebPage> getDepartmentHomeClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.DEPARTMENT_PROFILE_PATH);
		else
			return URLLoader.getPageClass(URLConstants.DEPT_PUBLIC_PAGE_HOME);
	}
	
	/**
	 * @return dept's courses page depending on user login
	 */
	public static final Class<? extends WebPage> getDepartmentCoursesPageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.DEPARTMENT_COURSES);
		else
			return URLLoader.getPageClass(URLConstants.DEPT_PUBLIC_PAGE_COURSES);
	}
	
	/**
	 * @return dept people page depending on user login condition
	 */
	public static final Class<? extends WebPage> getDepartmentPeoplePageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.DEPARTMENT_PEOPLE);
		else
			return URLLoader.getPageClass(URLConstants.DEPT_PUBLIC_PAGE_PEOPLE);
	}

	/**
	 * 
	 * @return univ private page if logged-in user, else public page
	 */
	public static final Class<? extends WebPage> getUnivHomeClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.UNIVERSITY_PROFILE_PATH);
		else
			return URLLoader.getPageClass(URLConstants.UNIV_PUBLIC_PAGE_HOME);
	}
	
	/**
	 * @return univ dept page depending on user login condition
	 */
	public static final Class<? extends WebPage> getUnivDeptPageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.UNIVERSITY_DEPT);
		else
			return URLLoader.getPageClass(URLConstants.UNIV_PUBLIC_PAGE_DEPT);
	}
	
	/**
	 * @return univ courses page based on user log-in condition
	 */
	public static final Class<? extends WebPage> getUnivCoursesPageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.UNIVERSITY_COURSES);
		else
			return URLLoader.getPageClass(URLConstants.UNIV_PUBLIC_PAGE_COURSES);
	}
	
	/**
	 * @return get univ people page based on login condition
	 */
	public static final Class<? extends WebPage> getUnivPeoplePageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.UNIVERSITY_PEOPLE);
		else
			return URLLoader.getPageClass(URLConstants.UNIV_PUBLIC_PAGE_PEOPLE);
	}
	
	
	/**
	 * @return user's home page based on login condition
	 */
	public static final Class<? extends WebPage> getUserHomeClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.USER_PROFILE_PATH);
		else
			return URLLoader.getPageClass(URLConstants.USER_PUBLIC_PAGE_SUMMARY);
	}
	
	/**
	 * @return user's department page depending on login condition
	 */
	public static final Class<? extends WebPage> getUserDeptPageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.USER_DEPARTMENT);
		else
			return URLLoader.getPageClass(URLConstants.USER_PUBLIC_PAGE_DEPTS);
	}
	
	/**
	 * @return univ courses page based on user login condition
	 */
	public static final Class<? extends WebPage> getUserCoursesPageClass(){
		if(isLoggedIn())
			return URLLoader.getPageClass(URLConstants.USER_COURSES);
		else
			return URLLoader.getPageClass(URLConstants.USER_PUBLIC_PAGE_COURSES);
	}
	
	private static boolean isLoggedIn() {
		return EduShareSession.get().isLoggedIn();
	}

	public static Class<? extends WebPage> getCalendarPageClass(Integer creatorTypeFromSchedules) {
		if(creatorTypeFromSchedules == Schedules.CREATOR_TYPE_UNIV){
			return URLLoader.getPageClass(URLConstants.UNIVERSITY_CALENDAR);
		}else if(creatorTypeFromSchedules == Schedules.CREATOR_TYPE_DEPT){
			return URLLoader.getPageClass(URLConstants.DEPARTMENT_CALENDAR);
		}else if(creatorTypeFromSchedules == Schedules.CREATOR_TYPE_COURSE){
			return URLLoader.getPageClass(URLConstants.COURSE_CALENDAR);
		}else if(creatorTypeFromSchedules == Schedules.CREATOR_TYPE_USER){
			return URLLoader.getPageClass(URLConstants.USER_CALENDAR);
		}
		return null;
	}

}
